def remaining_space(flowerbed: list[int], result_limit: int = -1) -> int:
    result = 0
    starting = -1
    length = len(flowerbed)

    if result_limit < 0:
        def to_the_limit(r: int):
            return False
    else:
        def to_the_limit(r: int):
            return r >= result_limit

    def space_between(left: int, right: int):
        f = right if left < 0 else (right - left - 2)
        return f // 2

    for ending in range(length):
        if flowerbed[ending] == 0:
            continue
        result += space_between(starting, ending)
        if to_the_limit(result):
            return result_limit
        starting = ending

    result += space_between(starting, length + 1)
    return result_limit if to_the_limit(result) else result


def _main():
    flowerbed: list[int] = eval(input("s = "))
    appending: int = int(input("n = "))
    print(remaining_space(flowerbed, appending) >= appending)


if __name__ == "__main__":
    _main()
